<?php
class img extends htmlwidget {

	public function __construct($src = ''){
		$this->tag = 'img';
		$this->validAttributes[] = 'width';
		$this->validAttributes[] = 'height';
		$this->validAttributes[] = 'align';
		$this->validAttributes[] = 'valign';
		$this->validAttributes[] = 'border';
		$this->validAttributes[] = 'alt';
		$this->validAttributes[] = 'src';
		$this->validAttributes[] = 'hspace';
		$this->validAttributes[] = 'vspace';

		if ( (! empty($src)) || (strlen($src)) ){
			$this->attributes['src'] = $src;
		}
		$this->attributes['border'] = 0;
	}

	public function __toString(){
		//open tag
		$this->html = "<";
		$this->html .= $this->tag;
		foreach ( $this->attributes as $key => $value){
			if ( ! empty($value) || strlen($value)){
				$this->html .= ' ' . $key . '="' . $value . '"';
			}
		}
		$this->html .= '>';
		return $this->html;
	}
	
	public function setBorder($value){
		$this->attributes['border'] = 0;		
	}
	
	public function border($value = 1){
		$this->attributes['border'] = 0;
	}
	
	public function noborder(){
		$this->attributes['border'] = 0;
	}
	

	public function setalt($altvalue){
		$this->attributes['alt'] = $altvalue;
	}
		
	public function alt($altvalue){
		$this->attributes['alt'] = $altvalue;
	}
	
	public function setwidth($width){
		$this->attributes['width'] = $width;
	}
	
	public function width($width){
		$this->attributes['width'] = $width;
	}
	
	
	public function setheight($height){
		$this->attributes['height'] = $height;
	}
	
	public function height($height){
		$this->attributes['height'] = $height;
	}
	
	public function setsrc($src){
		$this->attributes['src'] = $src;
	}

	public function src($src){
		$this->attributes['src'] = $src;
	}

	public function setalign($value){
		$this->attributes['align'] = $value;
	}
	
	public function align($value){
		$this->attributes['align'] = $value;
	}
	
	public function setvalign($value){
		$this->attributes['valign'] = $value;
	}
	
	public function valign($value){
		$this->attributes['valign'] = $value;
	}
}
?>